#set variables so everything can be found...
#100622 PKG_CONFIG_PATH is determined in 3builddistro (Woof), written to /etc/profile.d/pkgconfig
#110426 added /usr/games to PATH
#110804 fix double-login when exit from X, allow /etc/profile to complete. see also "echo -n '# '" in /usr/bin/xwin at exit.
#110807 revert 110804
#120221 moved code to start X to /root/.profile
#120407 hide error msg on screen if 915resolution fails.
#120525 shinobar: we don't need this: export LC_COLLATE=en_US
#130224 npierce: fix hard-to-see yellow text in terminal.
#140627 add 64 support

ARCH=`uname -m`
[ "$ARCH" = "x86_64" ] && lsuffix=64 || lsuffix=

PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin:/root/my-applications/bin:/usr/games"
LD_LIBRARY_PATH="/lib${lsuffix}:/usr/lib${lsuffix}:/usr/X11R7/lib:/root/my-applications/lib:/usr/local/lib"

if [ -d /opt/gnome2 ];then
 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/gnome2/lib"
 PATH="$PATH:/opt/gnome2/bin"
fi

if [ -d /opt/qt4 ];then
 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt4/lib"
 [ -d /opt/qt4/bin ] && PATH="$PATH:/opt/qt4/bin" #if devx sfs.
 export QT4DIR="/opt/qt4"
 [ -d /opt/qt4/include ] && export CPLUS_INCLUDE_PATH="/opt/qt4/include" #devx
fi

#v3.99 added, for older qt3...
if [ -e /usr/lib${lsuffix}/qt ];then
 export QTDIR=/usr/lib${lsuffix}/qt
 [ -d /usr/lib${lsuffix}/qt/bin ] && PATH=/usr/lib${lsuffix}/qt/bin:${PATH}
 LD_LIBRARY_PATH=/usr/lib${lsuffix}/qt/lib:$LD_LIBRARY_PATH
fi
export QT_XFT=true

if [ -d /opt/mozilla.org ];then #101220 path fixes.
 [ -e /opt/mozilla.org/lib/mozilla ] && LD_LIBRARY_PATH="/opt/mozilla.org/lib/mozilla:${LD_LIBRARY_PATH}"
 [ -e /opt/mozilla.org/lib/firefox ] && LD_LIBRARY_PATH="/opt/mozilla.org/lib/firefox:${LD_LIBRARY_PATH}"
 [ -d /opt/mozilla.org/bin ] && PATH="/opt/mozilla.org/bin:${PATH}" #may not exist.
 [ -e /opt/mozilla.org/lib/mozilla ] && export MOZILLA_FIVE_HOME="/opt/mozilla.org/lib/mozilla"
 [ -e /opt/mozilla.org/lib/firefox ] && export MOZILLA_FIVE_HOME="/opt/mozilla.org/lib/firefox"
fi

MOZ_PLUGIN_PATH="/usr/lib${lsuffix}/mozilla/plugins"
if [ -e /usr/lib${lsuffix}/seamonkey ];then
 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib${lsuffix}/seamonkey"
 export MOZILLA_FIVE_HOME="/usr/lib${lsuffix}/seamonkey"
 MOZ_PLUGIN_PATH="${MOZ_PLUGIN_PATH}:/usr/lib${lsuffix}/seamonkey/plugins"
fi

FIREFOX=$(find /usr/lib${lsuffix} -type d -name 'firefox*'|tail -1) #slacko
if [ -d "$FIREFOX" ];then
  LD_LIBRARY_PATH="$FIREFOX:$LD_LIBRARY_PATH"
  export MOZILLA_FIVE_HOME="$FIREFOX"
fi

if [ -d /opt/samba ];then
 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/samba/lib"
 PATH="$PATH:/opt/samba/bin"
fi

export PATH LD_LIBRARY_PATH MOZ_PLUGIN_PATH
export MOZ_DISABLE_PANGO=1
export GDK_USE_XFT=1 #for gtk...
export OOO_FORCE_DESKTOP="gnome" #Open Office, force ue of GTK...

ulimit -c 0
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
 umask 002
else
 umask 022
fi
USER=`id -un`
PS1="# "
LOGNAME=$USER
HISTSIZE=1000
HISTFILE="$HOME/.history"
EDITOR=mp
INPUTRC=/etc/inputrc
TERM="xterm"
[ -d /usr/share/terminfo ] && export TERMINFO=/usr/share/terminfo

# used by XRN, change to your news server...
# NNTPSERVER="news.dodo.com.au"
# GS_FONTPATH="/usr/lib/X11/fonts/Type1"
export PS1 USER LOGNAME HISTSIZE INPUTRC EDITOR TERM
XFINANSDIR="/root/.xfinans"
export XFINANSDIR

export XLIB_SKIP_ARGB_VISUALS=1 #rox crashes with DRI modules. solution:

#this line gets edited by chooselocale script...
#LANG=en_US.UTF-8
LANG=en_US
export LANG

HOSTNAME="`cat /etc/hostname | tr -d "\n"`"
export HOSTNAME

SHELL="/bin/bash"
export SHELL

##Sylpheed 2.0.1 requires this (also some other gtk2 apps)...
export G_FILENAME_ENCODING=@locale
export MM_RUNASROOT=1 #sylpheed uses metamail which requires this...

DEFAULTBROWSER="`cat /usr/local/bin/defaultbrowser | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTDRAW="`cat /usr/local/bin/defaultdraw  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTHTMLEDITOR="`cat /usr/local/bin/defaulthtmleditor  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTMEDIAPLAYER="`cat /usr/local/bin/defaultmediaplayer  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTPAINT="`cat /usr/local/bin/defaultpaint  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTSPREADSHEET="`cat /usr/local/bin/defaultspreadsheet  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTTEXTEDITOR="`cat /usr/local/bin/defaulttexteditor  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTWORDPROCESSOR="`cat /usr/local/bin/defaultwordprocessor  | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTIMAGEVIEWER="`cat /usr/local/bin/defaultimageviewer | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
DEFAULTIMAGEEDITOR="`cat /usr/local/bin/defaultimageeditor | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
export DEFAULTBROWSER DEFAULTDRAW DEFAULTHTMLEDITOR DEFAULTMEDIAPLAYER DEFAULTPAINT DEFAULTSPREADSHEET DEFAULTTEXTEDITOR DEFAULTWORDPROCESSOR DEFAULTIMAGEVIEWER DEFAULTIMAGEEDITOR

#v2.02 rarsa provided this...
#freedesktop base directory spec: standards.freedesktop.org/basedir-spec/latest/
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_DIRS=/usr/share:/usr/local/share
export XDG_CONFIG_DIRS=/etc/xdg #v2.14 changed from /usr/etc
export XDG_CACHE_HOME=$HOME/.cache

export HISTFILESIZE=2000
export HISTCONTROL=ignoredups

#w468 'netpbm' utilities need to be told where rgb.txt is...
[ -f /usr/share/X11/rgb.txt ] && export RGBDEF=/usr/share/X11/rgb.txt

export PREFIX='/usr' #convenient to set this i think...

#xorgwizard creates this file, run once only...
if [ ! -f /tmp/bootcnt.txt ];then
 [ -f /etc/resolutionfix ] && eval `cat /etc/resolutionfix` 2>/dev/null #120407
fi

#v2.16 this need arose when considering SFS files that may require special env. variables.
#this code is lifted straight from Vector...
# Append any additional sh scripts found in /etc/profile.d/:
#for profile_script in /etc/profile.d/*.sh ; do
for profile_script in /etc/profile.d/* ; do #w482 any files.
 [ "`echo -n "$profile_script" | grep 'txt$'`" != "" ] && continue #w482
. $profile_script
done
unset profile_script

#v2.16 have gone to full ls, now need this...
#auto: only creates ansi color codes if o/p to a tty, not in a script...
alias ls='ls --color=auto'

#130224 npierce: fix hard-to-read yellow in white terminal. refer: http://murga-linux.com/puppy/viewtopic.php?t=84298&start=210
export LS_COLORS='bd=33:cd=33' #refer http://blog.twistedcode.org/2008/04/lscolors-explained.html

#personal customisation file...
[ -r /etc/profile.local ] && . /etc/profile.local

# fix gtk3 WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
export NO_AT_BRIDGE=1

###END###
